import java.io.*;
import java.net.Socket;
//客户端：数据来自于键盘输入，直到输入的数据是886, 发送数据结束

public class TCP_Demo2_client {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("192.168.191.1", 10001);
        //自己封装字符缓冲输入流
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
        //创建字符缓冲输出流，配合字符缓冲输入流使用
        BufferedWriter bufferedWriter = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        String line;
        while( (line = bufferedReader.readLine()) != null){
            if(line.equals("886")) break;
            bufferedWriter.write(line);
            bufferedWriter.newLine();
            bufferedWriter.flush();
        }

        socket.close();
    }
}
